<script lang="jsx" setup>
import { ref } from 'vue';
import { Empty } from 'ant-design-vue';
import { getEngineeringDataInquiry } from '@/service/api/modules/engineering-manage/engineering-data-inquiry';
const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE;

const imgSrc = ref(null);

const isLocalHost = window.location.hostname === 'localhost';

function getData(params) {
  getEngineeringDataInquiry(params).then(({ data, error }) => {
    if (!error) {
      console.log(data);
      if (data.image) {
        imgSrc.value = `${isLocalHost ? 'http://192.168.166.166/dev-api/' : '/dev-api/'}${data.image}`;
      } else {
        imgSrc.value = null;
      }
    }
  });
}

defineExpose({
  getData
});
</script>

<template>
  <div class="h-full w-full flex-center">
    <template v-if="imgSrc">
      <AImage :src="imgSrc" />
    </template>
    <template v-else>
      <AEmpty :image="simpleImage" description="暂无开料图" />
    </template>
  </div>
</template>

<style lang="scss" scoped></style>
